<div class="m-tab s-tab">
	<h2 class="u-tt">用户组管理</h2>
	<ul>
		<li><a href="{$url|'UserGroup/index'}">用户组列表</a></li>
		<li class="z-crt"><a href="javascript:;">设置权限</a></li>
	</ul>
</div>
<div class="m-form">
	<form name="" action="<?php echo url('UserGroup/purviewData'); ?>" method="post" id="form">
		<fieldset>
			<div class="formitm">
				<label class="lab">用户组：</label>
				<div class="ipt"> {$info.name}
					<p></p>
				</div>
			</div>
			<div class="formitm">
				<label class="lab">选择系统权限：</label>
				<div class="ipt">
					<button class="u-btn" type="button" id="selectPurvew">全选/反选</button>
					<span class="suffix">选择模块后续功能才能使用</span> </div>
			</div>
			<?php
        if(!empty($AdminPurvew)){ foreach ($AdminPurvew as $key => $app) {if(!empty($app)){ foreach ($app as $listMode => $list) { ?>
			<div class="formitm">
				<label class="lab">{$list.name}：</label>
				<div class="ipt">
					<label class="u-opt">
						<input name="AdminPurvew[]" class="AdminPurvew" {if="in_array($key.'_'.$listMode,(array)$AdminPurvewArray)"} checked {/if} type="checkbox" value="{$key}_{$listMode}">
						模块</label>
					<?php if(!empty($list['auth'])){ foreach ($list['auth'] as $action => $vo) { ?>
					<?php if(in_array($key.'_'.$listMode.'_'.$action,(array)$AdminPurvewArray)){ $checked='checked'; }else { $checked= '' ;} ?>
					<label class="u-opt">
						<input name="AdminPurvew[]" class="AdminPurvew" {$checked} type="checkbox" value="{$key}_{$listMode}_{$action}">
						{$vo}</label>
					&nbsp;&nbsp;
					<?php }} ?>
				</div>
				<div class="f-cb"></div>
			</div>
			<?php } } } } ?>
			<div class="formitm">
				<label class="lab">选择菜单权限：</label>
				<div class="ipt">
					<button class="u-btn" type="button" id="selectMenu">全选/反选</button>
					<span class="suffix">选择模块后续功能才能使用</span> </div>
			</div>
			<?php if(!empty($AdminMenu)){ foreach ($AdminMenu as $topLabel => $top) {?>
			<div class="formitm ">
				<label class="lab">{$top.name}：</label>
				<div class="ipt">
				<?php if(!empty($top['menu'])){ foreach ($top['menu'] as $parentLabel => $parent) { ?>
				<fieldset class="m-fieldset">
					<legend ><label class="u-opt">
						<input name="AdminMenu[]" class="AdminMenu" type="checkbox" {if="in_array($topLabel.'_'.$parentLabel,(array)$AdminMenuArray)"} checked {/if}  value="<?php echo $topLabel.'_'.$parentLabel; ?>">
						{$parent.name} 
						</label></legend> 
						<?php if(!empty($parent['menu'])){ foreach ($parent['menu'] as $menuLabel => $menu) { ?>
						<label class="u-opt">
						<input name="AdminMenu[]" class="AdminMenu" type="checkbox" {if="in_array($menu['url'],(array)$AdminMenuArray)"} checked {/if}  value="<?php echo $menu['url']; ?>">
						{$menu.name}</label>
						<?php } } ?>
				</fieldset>
				<?php } } ?>
				</div>
				<div class="f-cb"></div>
			</div>
			<?php } } ?>
			<div class="formitm formitm-1  formitm-2">
				<input name="group_id" type="hidden" value="{$info.group_id}" />
				<button class="u-btn" type="submit">保存</button>
				<button class="u-btn s-btn-c3" type="reset">重置</button>
				<span class="status" id="status"></span> </div>
		</fieldset>
	</form>
</div>
<script>
Do.ready('base','form','dialog',function() {
	$('#selectPurvew').click(function() {
		$(".AdminPurvew").each(function(){
		if($(this).attr('checked')){   
			  $(this).removeAttr("checked");   
		}else{   
			  $(this).attr("checked",'true');   
		}   
		})
	});
	$('#selectMenu').click(function() {
		$(".AdminMenu").each(function(){
		if($(this).attr('checked')){   
			  $(this).removeAttr("checked");   
		}else{   
			  $(this).attr("checked",'true');   
		}   
		})
	});
	$('#form').duxForm({returnUrl:'{$url|"UserGroup/index"}'});
});
</script>